package network;

import sun.java2d.windows.GDIWindowSurfaceData;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

public class UdpDictServer extends UdpEchoServer {
    //要有一个哈希表
    private HashMap<String,String> dict = null;

    public UdpDictServer(int port) throws SocketException {
        super(port);

        dict = new HashMap<>();
        dict.put("hello","你好");
        dict.put("animal","动物");
        dict.put("money","金钱");
        dict.put("bonus","奖金");
        //单词查询软件就是这样搞来的
    }
    //重写父类的process方法


    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"该词没有查询到");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(9090);
        server.start();
    }



}
